<?php
function GetAll()
{
    $conn = getConnection();    
    return $conn->query('SELECT * FROM 2011_Users');
}

function Get($id)
{
    $conn = getConnection();
    $result = $conn->query('SELECT * FROM 2011_Users WHERE id='.$id);
    $rs = $result->fetch_assoc();
    $conn->close();
    return $rs;
}

function GetUsersId($LastName, $Password)
{
	$conn = getConnection();
	$result = $conn->query("SELECT * FROM 2011_Users WHERE LastName='$LastName' AND Password='$Password'");
	$rs = $result->fetch_assoc();
	$userId = $rs['id'];
	$conn->close();
	return $userId;
}

function GetTypeid($id)
{
	$conn = getConnection();
	$result = $conn->query('SELECT * FROM 2011_Types WHERE id='.$id);
	$type = $result->fetch_assoc();
	$conn->close();
	return $type;
}

function GetContactInfo($id)
{
	$conn = getConnection();
	$result = $conn->query("SELECT * FROM 2011_ContactMethods WHERE User_id = '$id'");
	$contact = $result->fetch_assoc();
	$conn->close();
	return $contact;
}

function GetShippingAdd($id)
{
	$conn = getConnection();
	$result = $conn->query('SELECT * FROM 2011_Addresses WHERE Type_id=4 AND User_id='.$id);
	$address = $result->fetch_assoc();
	$conn->close();
	return $address;
}

function GetBillingAdd($id)
{
	$conn = getConnection();
	$result = $conn->query('SELECT * FROM 2011_Addresses WHERE Type_id=5 AND User_id='.$id);
	$baddress = $result->fetch_assoc();
	$conn->close();
	return $baddress;
}

function Get_User_Name($id)
{
	$conn = getConnection();
	$result = $conn->query("SELECT * FROM 2011_Users WHERE id = '$id'");
	$UserName = $result->fetch_assoc();
	$conn->close();
	return $UserName;
}
function Save($rs)
{
}

function Delete($id)
{
	$conn = getConnection();
	$result = $conn->query("DELETE FROM 2011_Users WHERE id = '$id'");
	$result = $conn->query("DELETE FROM 2011_ContactMethods WHERE User_id = '$id'");
	$conn->close();
}
?>